package com.zgm.ch05.aop.pointcutAdvisor._4_1_4;

import java.lang.reflect.Method;

import org.springframework.aop.ClassFilter;
import org.springframework.aop.support.DynamicMethodMatcherPointcut;

public class SimpleDynamicPointcut extends DynamicMethodMatcherPointcut {

	

	@Override
	public boolean matches(Method method, Class targetClass) {
		System.out.println("静态检查： " + method.getName());
		return ("foo".equals(method.getName()));
	}

	public boolean matches(Method method, Class targetClass, Object[] args) {
		System.out.println("动态检查： " + method.getName());
		int x = (Integer) args[0];
		
		return (x != 100);
	}
	
	@Override
	public ClassFilter getClassFilter() {
		return new ClassFilter() {
				public boolean matches(Class clazz) {
					return (clazz == SimpleBean.class);
				}
			};
	}

}
